<!DOCTYPE html>
{% load static %}
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录系统</title>
    <!-- AdminLTE CSS -->
    <link rel="stylesheet" href="{% static 'css/adminlte.min.css' %}">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="{% static 'css/all.min.css' %}">
    <!-- jQuery -->
    <script src="{% static 'js/jquery.min.js' %}"></script>
    <!-- Bootstrap 4 -->
    <script src="{% static 'js/bootstrap.bundle.min.js' %}"></script>
    <!-- AdminLTE App -->
    <script src="{% static 'js/adminlte.min.js' %}"></script>
    <style>
        body {
            background-color: #f8f9fa;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            margin: 0;
        }
        .login-box {
            width: 100%;
            max-width: 450px;
            padding: 20px;
        }
        .login-logo {
            text-align: center;
            margin-bottom: 30px;
            font-size: 28px;
            font-weight: 600;
            color: #333;
        }
    </style>
</head>
<body class="hold-transition login-page">
    <div class="login-box">
        <div class="login-logo">
            <i class="fas fa-chart-line mr-2"></i> <span class="mb-2">{{ PROJECT_TITLE }}数据可视化</span>
            <div><b>系统登录</b></div>
        </div>
        <!-- /.login-logo -->
        <div class="card card-primary">
            <div class="card-header">
                <h3 class="card-title">用户登录</h3>
            </div>
            <!-- /.card-header -->
            <!-- form start -->
            <form method="post">
                {% csrf_token %}
                <div class="card-body">
                    {% if form.errors %}
                        <div class="alert alert-danger alert-dismissible">
                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                            <h5><i class="icon fas fa-ban"></i> 登录失败</h5>
                            用户名或密码错误，请重试。
                        </div>
                    {% endif %}
                    
                    {% if next %}
                        {% if user.is_authenticated %}
                            <div class="alert alert-warning alert-dismissible">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                                <h5><i class="icon fas fa-exclamation-triangle"></i> 警告</h5>
                                您的账号没有权限访问该页面。
                            </div>
                        {% else %}
                            <div class="alert alert-info alert-dismissible">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                                <h5><i class="icon fas fa-info"></i> 请登录</h5>
                                请登录以访问该页面。
                            </div>
                        {% endif %}
                    {% endif %}
                    
                    <div class="form-group">
                        <label for="username">用户名</label>
                        <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户名" required>
                    </div>
                    <div class="form-group">
                        <label for="password">密码</label>
                        <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码" required>
                    </div>
                    <div class="form-group">
                        <div class="form-check">
                            <input type="checkbox" class="form-check-input" id="remember-me">
                            <label class="form-check-label" for="remember-me">记住我</label>
                        </div>
                    </div>
                </div>
                <!-- /.card-body -->

                <div class="card-footer">
                    <button type="submit" class="btn btn-primary btn-block">登录</button>
                    <input type="hidden" name="next" value="{{ next }}">
                </div>
            </form>
        </div>
        <!-- /.card -->
    </div>
    <!-- /.login-box -->

    <script>
        $(function() {
            // 添加表单输入样式
            $('.form-control').addClass('form-control');
            $('select').addClass('form-control');
            $('textarea').addClass('form-control');
        });
    </script>
</body>
</html>